#!/usr/bin/env python
#coding:utf-8
import sys
from thrift.Thrift import TMessageType
from thrift.Thrift import TType

class ContextSeralize(object):
    """docstring for ContextSeralize"""

    _parrotContext = '$$$_1_PC$$$$$$$$__1_&_8_#'

    def __init__(self, vals = None):
        self.arg0 = vals
        # print self.arg0

    def read(self, input):
        _size7 = 0
        _ktype8 = 0
        _vtype9 = 0
       
        rseqid = 0
        fname = None
        mtype = 0

        (fname, mtype, rseqid) = input.readMessageBegin()
        print fname, mtype, rseqid
        (tmp_len, fname, mtype, rseqid) = input.readMessageBeginJM()
        (tmp_len, _ktype8, _vtype9, _size7) = input.readMapBeginJM()
        xfer += tmp_len
        for x in xrange(0, _size7):
            key12 = ''
            key13 = ''
            (tmp_len1, key12) = input.readStringJM()
            (tmp_len2, key13) = input.readStringJM()
            self.arg0[key12] = key13
            xfer += tmp_len1 + tmp_len2
        xfer += input.readMapEnd()
        xfer += input.readMessageEnd()
        context = self.arg0


    def write(self, output):
        xfer = 0
        xfer += output.writeMessageBeginJM(self._parrotContext, TMessageType.CALL, 0)
        xfer += output.writeMapBeginJM(TType.STRING, TType.STRING, len(self.arg0))
        for (key14, val15) in self.arg0.items():
            xfer += output.writeStringJM(key14)
            xfer += output.writeStringJM(val15)
        output.writeMapEnd()
        output.writeMessageEnd()
        return xfer

